class Solution {
public:
    vector<vector<int>> pairSums(vector<int>& nums, int target) {
        vector<vector<int>> ans;
        int left=0;
        int right=nums.size()-1;
        sort(nums.begin(),nums.end());
        while(left<right)
        {
            vector<int> temp;
            if(nums[left]+nums[right]==target)
            {
                temp.push_back(nums[left]);
                temp.push_back(nums[right]);
                left++;
                right--;
                ans.push_back(temp);
            }
            else if(nums[left]+nums[right]>target)
            {
                right--;
            }
            else
            {
                left++;
            }
        }
        return ans;
    }
};